package com.zxy.salenet.web.service.imple;

import com.zxy.salenet.web.mapper.SalenetGoodsMapper;
import com.zxy.salenet.web.pojo.SalenetGoods;
import com.zxy.salenet.web.service.UserHomeService;
import com.zxy.salenet.web.pojo.vo.HomeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: zxy
 * @version: 1.0
 * @description:    用户首页显示视图实现类
 */
   /**
 * UserHomeServiceImpl
 */
@Service
public class UserHomeServiceImpl implements UserHomeService {
    @Autowired
    private SalenetGoodsMapper goodsMapper;
    /**
     * 获取首页显示的信息
     * @return
     */
    @Override
    public HomeVO queryHomeAllMessage() {
        //创建界面视图vo
        HomeVO homeVO = new HomeVO();
        //获取特价商品 特价商品为4
        List<SalenetGoods> bargainList = goodsMapper.selectBargainListAll();
        //获取今日上新商品 上新商品获取今天上新的商品  按照时间
        List<SalenetGoods> newAddGoodsList = goodsMapper.selectNewGoods();

        //以下商品都是取10个
        Map<String,List<SalenetGoods>> otherGoodsMap = new HashMap<>();
        //获取种类为项链的商品 type_id = 99
        List<SalenetGoods> aGoods = goodsMapper.selectAGoodsList();

        //获取种类为戒指的商品  107
        List<SalenetGoods> bGoods = goodsMapper.selectBGoodsList();

        //获取种类为玉石的商品  88
        List<SalenetGoods> cGoods = goodsMapper.selectCGoodsList();

        //获取种类为口红的商品  77
        List<SalenetGoods> dGoods = goodsMapper.selectDGoodsList();

        //获取种类为香水的商品  44
        List<SalenetGoods> eGoods = goodsMapper.selectEGoodsList();

        otherGoodsMap.put("necklace",aGoods);
        otherGoodsMap.put("ring",bGoods);
        otherGoodsMap.put("jade",cGoods);
        otherGoodsMap.put("lipstick",dGoods);
        otherGoodsMap.put("perfume",eGoods);
        // TODO: 2021/3/3

        //获取特价商品
        homeVO.setBargainList(bargainList);
        //获取今日上新
        homeVO.setTodayNewGoods(newAddGoodsList);
        //获取其他商品分类显示的商品
        homeVO.setOtherGoodsList(otherGoodsMap);
        return homeVO;
    }
}
